﻿using System.Windows;
using System.Runtime.Serialization;

using Game.Map;

namespace Game.Level
{
    public class GameLevelDependencyObject : DependencyObject
    {
    }

    [DataContract(Namespace = "game")]
    public class GameLevel 
    {
        [DataMember(Name = "Milestones")]
        public readonly GameMilestones _GameMilestones = new GameMilestones();

        [DataMember(Name = "Map")]
        public IGameMap _GameMap;

        readonly string _Name;

        GameLevelDependencyObject _DependencyObject = new GameLevelDependencyObject();

        public static GameLevel Create(
            GameLevels levels)
        {
            var level = new GameLevel("Level" + (levels.Count + 1));
            levels.Add(level);

            level.Milestones.Add(new GameMilestone(GameMilestoneType.Start, ""));
            level.Milestones.Add(new GameMilestone(GameMilestoneType.Success, ""));
            level.Milestones.Add(new GameMilestone(GameMilestoneType.Failure, ""));
            return level;
        }

        public GameLevel()
            : this("temp")
        {
        }

        public GameLevel(string name)
        {
            _Name = name;
            _GameMap = Factory.Create();
        }

        [OnDeserialized]
        public void OnDeserialized2(StreamingContext c)
        {
            _DependencyObject = new GameLevelDependencyObject();
        }

        public string Name
        {
            get { return _Name; }
        }

        public GameLevelDependencyObject DependencyObject 
        {
            get { return _DependencyObject; }
        }

        public IGameMap GameMap
        {
            get { return _GameMap; }
            set { _GameMap=value; }
        }

        public GameMilestones Milestones
        {
            get { return _GameMilestones; }
        }

    }

}
